home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume6 / glib / part11 < prev    next >
Encoding:
Text File  |  1989-05-14  |  32.4 KB  |  1,254 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v06i112: glib part 11 of 15
  4. Reply-To: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  5.  
  6. Posting-number: Volume 6, Issue 112
  7. Submitted-by: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  8. Archive-name: glib/part11
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 11 (of 15)."
  17. # Contents:  menutoc.c
  18. # Wrapped by lee@uhccux on Sun May  7 00:40:18 1989
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'menutoc.c' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'menutoc.c'\"
  22. else
  23. echo shar: Extracting \"'menutoc.c'\" \(30374 characters\)
  24. sed "s/^X//" >'menutoc.c' <<'END_OF_FILE'
  25. X#define YY_DEFAULT_ACTION ECHO;
  26. X#define FLEX_USE_ECS
  27. X#define FLEX_USE_MECS
  28. X/* A lexical scanner generated by flex */
  29. X
  30. X/* macro definitions for compressed-table C/FTL programs generated by flex */
  31. X
  32. X/* common macro definitions for C/FTL programs generated by flex */
  33. X
  34. X
  35. X/* returned upon end-of-file */
  36. X#define YY_END_TOK 0
  37. X
  38. X/* action number for an "end-of-file was seen and yywrap indicated that we
  39. X * should continue processing"
  40. X */
  41. X#define YY_NEW_FILE -1
  42. X
  43. X/* action number for "the default action should be done" */
  44. X#define YY_DO_DEFAULT -2
  45. X
  46. X#ifndef BUFSIZ
  47. X#include <stdio.h>
  48. X#endif
  49. X
  50. X#define YY_BUF_SIZE (BUFSIZ * 2) /* size of input buffer */
  51. X
  52. X/* number of characters one rule can match.  One less than YY_BUF_SIZE to make
  53. X * sure we never access beyond the end of an array
  54. X */
  55. X#define YY_BUF_MAX (YY_BUF_SIZE - 1)
  56. X
  57. X/* we will never use more than the first YY_BUF_LIM + YY_MAX_LINE positions
  58. X * of the input buffer
  59. X */
  60. X#ifndef YY_MAX_LINE
  61. X#define YY_MAX_LINE BUFSIZ
  62. X#endif
  63. X
  64. X#define YY_BUF_LIM (YY_BUF_MAX - YY_MAX_LINE)
  65. X
  66. X/* copy whatever the last rule matched to the standard output */
  67. X
  68. X#define ECHO fputs( yytext, yyout )
  69. X
  70. X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  71. X * is returned in "result".
  72. X */
  73. X#define YY_INPUT(buf,result,max_size) \
  74. X    if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  75. X        YY_FATAL_ERROR( "read() in flex scanner failed" );
  76. X#define YY_NULL 0
  77. X
  78. X/* macro used to output a character */
  79. X#define YY_OUTPUT(c) putc( c, yyout );
  80. X
  81. X/* report a fatal error */
  82. X#define YY_FATAL_ERROR(msg) \
  83. X    { \
  84. X    fputs( msg, stderr ); \
  85. X    putc( '\n', stderr ); \
  86. X    exit( 1 ); \
  87. X    }
  88. X
  89. X/* returns the first character of the matched text */
  90. X#define YY_FIRST_CHAR yy_ch_buf[yy_b_buf_p]
  91. X
  92. X/* default yywrap function - always treat EOF as an EOF */
  93. X#define yywrap() 1
  94. X
  95. X/* enter a start condition.  This macro really ought to take a parameter,
  96. X * but we do it the disgusting crufty way that old Unix-lex does it
  97. X */
  98. X#define BEGIN yy_start = 1 +
  99. X
  100. X/* callable from YY_INPUT to set things up so that '%' will match.  Proper
  101. X * usage is "YY_SET_BOL(array,pos)"
  102. X */
  103. X#define YY_SET_BOL(array,pos) array[pos - 1] = '\n';
  104. X
  105. X/* default declaration of generated scanner - a define so the user can
  106. X * easily add parameters
  107. X */
  108. X#define YY_DECL int yylex()
  109. X
  110. X/* return all but the first 'n' matched characters back to the input stream */
  111. X#define yyless(n) \
  112. X    { \
  113. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
  114. X    yy_c_buf_p = yy_b_buf_p + n - 1; \
  115. X    YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  116. X    }
  117. X
  118. X/* code executed at the end of each rule */
  119. X#define YY_BREAK break;
  120. X
  121. X/* reinitializes everything except the current start condition.  The last
  122. X * input character is set to a newline so an initial beginning-of-line
  123. X * rule will match
  124. X */
  125. X#define YY_INIT \
  126. X    { \
  127. X    yyleng = yy_c_buf_p = yy_e_buf_p = 0; \
  128. X    yy_hold_char = yy_ch_buf[yy_c_buf_p] = '\n'; \
  129. X    yytext = &yy_ch_buf[yy_c_buf_p]; \
  130. X    yy_saw_eof = 0; \
  131. X    }
  132. X
  133. X/* returns the length of the matched text */
  134. X#define YY_LENG (yy_c_buf_p - yy_b_buf_p + 1)
  135. X/* done before the next pattern has been matched action */
  136. X#define YY_DO_BEFORE_SCAN \
  137. X    yytext[yyleng] = yy_hold_char;
  138. X
  139. X/* done after the current pattern has been matched and before the corresponding action */
  140. X#define YY_DO_BEFORE_ACTION \
  141. X    yytext = &yy_ch_buf[yy_b_buf_p]; \
  142. X    yyleng = YY_LENG; \
  143. X    yy_hold_char = yytext[yyleng]; \
  144. X    yytext[yyleng] = '\0';
  145. X
  146. X/* find the next rule matched */
  147. X#ifdef FLEX_REJECT_ENABLED
  148. X#define REJECT \
  149. X        { \
  150. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
  151. X        yy_c_buf_p = yy_full_match; /* restore possibly backed-over text */ \
  152. X        ++yy_lp; \
  153. X        goto find_rule; \
  154. X        }
  155. X#else
  156. X#define REJECT YY_FATAL_ERROR( "REJECT used and scanner was not generated using -r" )
  157. X#endif
  158. X
  159. X# line 1 "menutoc.l"
  160. X#define INITIAL 0
  161. X# line 2 "menutoc.l"
  162. X/* $Id: menutoc.c,v 1.6 89/05/06 17:13:36 lee Exp $
  163. X *    menutoc.l    -- Greg Lee, lee@uhccux.uhcc.hawaii.edu
  164. X *               February 1989
  165. X * $Author: lee $
  166. X * $Log:    menutoc.c,v $
  167. X * Revision 1.6  89/05/06  17:13:36  lee
  168. X * rel. to comp.sources.misc
  169. X * 
  170. X * Revision 1.6  89/05/06  09:51:46  lee
  171. X * Scott Snyder fixed a bug (see comment below)
  172. X * Mark Rinfret made a couple changes for Aztec C
  173. X * now emits some (INT16) casts for lint
  174. X * now emits #line directives
  175. X * 
  176. X * Revision 1.5  89/04/25  16:36:18  lee
  177. X * modifications:
  178. X * 
  179. X
  180. X    Generate C language menu module for Glib from menu specification.
  181. X
  182. XCompile:
  183. X    flex menutoc.l
  184. X    cc -o menutoc lex.yy.c
  185. Xor
  186. X    lex menutoc.l
  187. X    cc -o menutoc lex.yy.c -ll
  188. X
  189. XUsage:
  190. X    menutoc <file.menu >file.c
  191. X
  192. XDescription:
  193. X
  194. XMenutoc simplifies constructing and modifying synthesizer-specific
  195. Xmodules for Tim Thompson's Glib.  It allows the form of the on-screen
  196. Xmenu to be specified as a picture in the menu source file, and generates
  197. X'setval' and 'getval' calls automatically.  This version works with
  198. Xthe version of Glib modified by Michael Kesti.
  199. X
  200. X[The original version of flex distributed on Usenet has a bug which
  201. X prevents setting the start state.  If this is a problem, you can
  202. X fix it by making two changes to flex's skeleton files:
  203. X    CHANGE
  204. X    static int yy_start;
  205. X    TO
  206. X    static int yy_start = 0;
  207. X
  208. X    CHANGE
  209. X        yy_start = 1;
  210. X    TO
  211. X        if (!yy_start) yy_start = 1;
  212. X]
  213. X
  214. XThe following characterization of how menutoc works is probably
  215. Xnot entirely clear.  Look at the example k1single.menu and the
  216. Xsource code to get a more exact idea.  The source k1single.menu
  217. Xgives the C file k1single.c after processing by menutoc.
  218. X
  219. XThe menu source file should contain five special preprocessor
  220. Xdirectives: '#MENU' (once), '#END' (once), '#O' (one for each
  221. Xlabel name), '#GETVAL' (once), and '#SETVAL' (once).  The source
  222. Xfile has four sections:
  223. X    (1) the portion before the '#MENU' directive is passed
  224. X        through unchanged to the output,
  225. X    (2) a picture of the screen menu is given between the
  226. X        '#MENU' and '#END' directives,
  227. X    (3) after the '#END' directive is C code with '#O' directives
  228. X        which specify the data offsets of variables and with
  229. X        '%%' or '@@' references to the screen locations for
  230. X        variable values, and
  231. X    (4) more C code containing somewhere the '#SETVAL' and
  232. X        '#GETVAL' directives which cause a series of calls
  233. X        to the 'setval' and 'getval' functions to be generated,
  234. X        making use of the offset information given by the '#O'
  235. X        directives in the preceding section.
  236. X
  237. XThe picture of the screen menu has constant strings in the position
  238. Xthey will be output to the screen and '%' or '@' in each position
  239. Xwhere the current value of some variable is to be displayed by
  240. XGlib.  The locations of the '%'s and '@'s are remembered in the
  241. Xorder in which they are encountered (scanning left-to-right and
  242. Xtop-to-bottom in the picture), then the corresponding row/column
  243. Xcoordinates are substituted for '%%'s and '@@'s encountered in
  244. Xsection 3 of the source file.  The '%'s and '@'s are stored
  245. Xindependently so as to make it more convenient to specify menus
  246. Xthat have two columns of values.
  247. X
  248. XThe '#O' specifications are given in the form:
  249. X
  250. X#O <NAME> <TYPE> <POS> <MAX> <OFFSET> <MASK> <SHIFT> <ADHOC>
  251. X
  252. XSuch a line generates one "paraminfo" entry for an array, and some of
  253. Xthe information is saved and made use of in generating 'setval' and
  254. X'getval' calls.  NAME is the name of a variable label (no caps); TYPE is
  255. Xthe name of a vis-function used to display the current value on the
  256. Xscreen; POS should be either '%%' or '@@', which will be replaced by row
  257. Xand column coordinates of the position to display the value; MAX is the
  258. Xmaximum value the glib editor is to accept (the minimum is assumed to be
  259. X0); OFFSET is the offset of the byte containing the value in the data
  260. Xarray.  (If OFFSET is negative, the (positive) value is taken to be the
  261. Xinitial value rather than the offset.)
  262. X
  263. XThe NAME argument may begin with a digit specifying a repetition
  264. Xcount.  It's a shortcut which is like giving several consecutive
  265. X#O-lines for <NAME>1, <NAME>2, ...
  266. X
  267. XThe last three #O arguments are optional.  MASK is a number with 1-bits
  268. Xin positions holding the value for those cases where part of a byte is
  269. Xused for some other purpose.  SHIFT is the number of bits the bitfield
  270. Xis shifted left in the byte.  So, for instance, if the synth keeps a
  271. Xvalue in the 4th, 5th, and 6th bits, one would give '0x1C' for the MASK
  272. Xand '3' for SHIFT.  (Use caps for hex digits A-F.)
  273. X
  274. XThere is no systematic provision for values some of whose bits are found
  275. Xin one byte, some in another.  The ADHOC argument has the form
  276. X'*<digit>' and is used in the example to provide for such a case.  The
  277. Xcode below in this file was just made up ad hoc for two such cases I
  278. Xencountered with the Kawai K1.
  279. X
  280. X*/
  281. X
  282. X/*
  283. X * Modified 4-13-89 by Scott Snyder:
  284. X *  1. Increased MAXVAL from 100 to 200 (for DX7).
  285. X *  2. Changed type of temps from 'unsigned char' to 'unsigned' (for DX7).
  286. X *  3. Added command line processing (since TMAKE doesn't support redirection).
  287. X *
  288. X * 4-19-18
  289. X *  Fixed bug with zero offsets.
  290. X */
  291. X
  292. X#ifdef AZTEC_C
  293. Xlong atol();
  294. X# define strtol(a, b, c) atol(a)
  295. X#endif
  296. X#define MAXLINE 133
  297. X#define MAXVAL 200
  298. X#define MAXVSTRINGS 200
  299. X#define MAXBUF 2000
  300. X
  301. X    char *infname = "file.mnu";
  302. X    int lcnt = 1;
  303. X    int i, j, k, wcol=0, col=0, row=0;
  304. X    char word[MAXLINE];
  305. X    int wordp = 0;
  306. X    int valpos[MAXVAL][2];
  307. X    int valpos2[MAXVAL][2];
  308. X    int valcnt = 0;
  309. X    int valcnt2= 0;
  310. X    int offset;
  311. X    int nlist[MAXVSTRINGS][6];
  312. X    int np = 0;
  313. X    char buf[MAXBUF];
  314. X    int bufp=0;
  315. X    int multiple, special;
  316. X        int vmin, vmax, vval, mask, vshift, vrow, vcol, iflag;
  317. X    char visfunc[20];
  318. X    int state;
  319. X#define M 2
  320. X#define IG 4
  321. X#define VAL 6
  322. X#define O 8
  323. X#define P 10
  324. X#define Q 12
  325. X# line 160 "menutoc.l"
  326. X#define YY_JAM 92
  327. X#define YY_JAM_BASE 174
  328. X#define YY_TEMPLATE 93
  329. Xstatic char l[93] =
  330. X    {   0,
  331. X       -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
  332. X       -2,   -2,   -2,   -2,   33,    9,    7,    8,    6,    5,
  333. X        4,    9,    3,    2,    3,   23,   24,   23,   23,   23,
  334. X       23,   12,   13,   14,   15,   16,   17,   33,   33,   33,
  335. X       18,   33,    6,    0,    0,    0,    0,   30,   29,    0,
  336. X        0,    0,    0,    0,    0,   13,   14,   15,   16,   19,
  337. X       22,   21,   18,   20,    0,    0,   27,   28,    0,   11,
  338. X        0,    0,    0,    0,    0,    0,    0,   10,    0,    0,
  339. X        0,    0,    1,    0,    0,    0,    0,    0,   26,    0,
  340. X       25,    0
  341. X
  342. X    } ;
  343. X
  344. Xstatic char e[128] =
  345. X    {   0,
  346. X        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  347. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  348. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  349. X        1,    4,    1,    1,    5,    1,    6,    1,    1,    1,
  350. X        1,    7,    1,    1,    8,    1,    1,    9,   10,   10,
  351. X       10,   10,   10,   10,   10,   10,   10,    1,    1,    1,
  352. X        1,    1,    1,   11,   12,   13,   13,   14,   15,   13,
  353. X       16,    1,    1,    1,    1,   17,   18,   19,   20,    1,
  354. X        1,    1,   21,   22,   23,   24,    1,    1,    1,    1,
  355. X        1,   25,    1,    1,   26,    1,   27,   27,   27,   27,
  356. X
  357. X       27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
  358. X       27,   27,   27,   27,   27,   27,   27,   27,   27,   28,
  359. X       27,   27,    1,    1,    1,    1,    1
  360. X    } ;
  361. X
  362. Xstatic char m[29] =
  363. X    {   0,
  364. X        1,    1,    1,    1,    1,    1,    1,    2,    3,    3,
  365. X        1,    2,    2,    2,    2,    1,    1,    1,    1,    1,
  366. X        1,    1,    1,    1,    1,    4,    4,    3
  367. X    } ;
  368. X
  369. Xstatic short int b[104] =
  370. X    {   0,
  371. X        0,    0,    0,   10,  121,    2,   14,   37,    0,    9,
  372. X       61,    0,   88,    0,  174,  174,  174,  174,  119,  174,
  373. X      174,   20,  174,  174,   27,  174,  174,  116,  110,   27,
  374. X      115,  174,    0,   28,    0,   42,  174,  114,  108,  107,
  375. X      106,  102,  108,   45,   92,   48,   95,  174,  174,  103,
  376. X       97,   51,   92,   52,   91,    0,   55,    0,   71,  174,
  377. X      174,   97,   96,  174,   79,   67,   79,   73,   61,   72,
  378. X       60,   73,   77,   56,   54,   53,   66,  174,   65,   52,
  379. X       49,   55,  174,   34,   24,   31,   23,   20,  174,    5,
  380. X      174,  174,  136,  140,  144,  148,  150,  152,  155,  158,
  381. X
  382. X      162,  166,  170
  383. X    } ;
  384. X
  385. Xstatic short int d[104] =
  386. X    {   0,
  387. X       93,   93,   94,   94,   95,   95,   96,   96,   93,   93,
  388. X       93,   11,   93,   13,   92,   92,   92,   92,   92,   92,
  389. X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  390. X       92,   92,   97,   92,   98,   92,   92,   92,   92,   99,
  391. X       99,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  392. X       92,   92,   92,   92,   92,   97,   92,   98,   92,   92,
  393. X       92,   99,   99,   92,   92,   92,   92,   92,   92,   92,
  394. X       92,   99,  100,   92,   92,   92,  100,   92,  101,   92,
  395. X       92,  101,   92,   92,   92,  102,  103,  102,   92,  103,
  396. X       92,-32767,   92,   92,   92,   92,   92,   92,   92,   92,
  397. X
  398. X       92,   92,   92
  399. X    } ;
  400. X
  401. Xstatic short int n[203] =
  402. X    {   0,
  403. X       92,   17,   18,   19,   24,   20,   25,   91,   32,   32,
  404. X       21,   17,   18,   19,   22,   20,   27,   32,   32,   28,
  405. X       21,   44,   89,   44,   29,   91,   33,   33,   46,   57,
  406. X       46,   57,   50,   89,   45,   33,   33,   51,   30,   27,
  407. X       87,   31,   28,   59,   47,   59,   44,   29,   44,   46,
  408. X       86,   46,   52,   70,   52,   70,   57,   83,   57,   45,
  409. X       85,   30,   34,   84,   34,   47,   53,   83,   78,   35,
  410. X       35,   55,   59,   70,   59,   70,   81,   80,   79,   78,
  411. X       72,   76,   75,   68,   67,   74,   35,   35,   35,   36,
  412. X       37,   36,   73,   38,   39,   40,   41,   41,   42,   41,
  413. X
  414. X       41,   41,   41,   92,   72,   71,   69,   68,   67,   66,
  415. X       65,   43,   64,   92,   62,   41,   52,   61,   52,   60,
  416. X       49,   48,   43,   24,   92,   92,   92,   92,   92,   92,
  417. X       53,   92,   92,   92,   54,   55,   15,   15,   15,   15,
  418. X       16,   16,   16,   16,   23,   23,   23,   23,   26,   26,
  419. X       26,   26,   56,   56,   58,   58,   63,   63,   77,   77,
  420. X       77,   77,   82,   82,   82,   82,   88,   88,   88,   88,
  421. X       90,   90,   90,   90,   92,   92,   92,   92,   92,   92,
  422. X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  423. X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  424. X
  425. X       92,   92
  426. X    } ;
  427. X
  428. Xstatic short int c[203] =
  429. X    {   0,
  430. X        0,    3,    3,    3,    6,    3,    6,   90,    9,    9,
  431. X        3,    4,    4,    4,    4,    4,    7,   10,   10,    7,
  432. X        4,   22,   88,   22,    7,   87,    9,    9,   25,   34,
  433. X       25,   34,   30,   86,   22,   10,   10,   30,    7,    8,
  434. X       85,    8,    8,   36,   25,   36,   44,    8,   44,   46,
  435. X       84,   46,   52,   54,   52,   54,   57,   82,   57,   44,
  436. X       81,    8,   11,   80,   11,   46,   52,   79,   77,   11,
  437. X       11,   52,   59,   70,   59,   70,   76,   75,   74,   73,
  438. X       72,   71,   69,   68,   67,   66,   11,   11,   11,   13,
  439. X       13,   13,   65,   13,   13,   13,   13,   13,   13,   13,
  440. X
  441. X       13,   13,   13,   63,   62,   55,   53,   51,   50,   47,
  442. X       45,   43,   42,   41,   40,   13,   31,   39,   31,   38,
  443. X       29,   28,   19,    5,    0,    0,    0,    0,    0,    0,
  444. X       31,    0,    0,    0,   31,   31,   93,   93,   93,   93,
  445. X       94,   94,   94,   94,   95,   95,   95,   95,   96,   96,
  446. X       96,   96,   97,   97,   98,   98,   99,   99,  100,  100,
  447. X      100,  100,  101,  101,  101,  101,  102,  102,  102,  102,
  448. X      103,  103,  103,  103,   92,   92,   92,   92,   92,   92,
  449. X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  450. X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
  451. X
  452. X       92,   92
  453. X    } ;
  454. X
  455. X
  456. X/* these declarations have to come after the section 1 code or lint gets
  457. X * confused about whether the variables are used
  458. X */
  459. XFILE *yyin = stdin, *yyout = stdout;
  460. X
  461. X/* these variables are all declared out here so that section 3 code can
  462. X * manipulate them
  463. X */
  464. Xstatic int yy_start = 0, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
  465. Xstatic int yy_saw_eof, yy_init = 1;
  466. X
  467. X/* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
  468. X * setting up yytext we can try to put a '\0' just past the end of the
  469. X * matched text
  470. X */
  471. Xstatic char yy_ch_buf[YY_BUF_SIZE + 1];
  472. Xstatic int yy_st_buf[YY_BUF_SIZE];
  473. Xstatic char yy_hold_char;
  474. Xchar *yytext;
  475. Xstatic int yyleng;
  476. X
  477. XYY_DECL
  478. X    {
  479. X    int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
  480. X#ifdef FLEX_REJECT_ENABLED
  481. X    int yy_full_match;
  482. X#endif
  483. X
  484. X
  485. X
  486. X
  487. X    if ( yy_init )
  488. X    {
  489. X    YY_INIT;
  490. X    if (!yy_start) yy_start = 1;
  491. X    yy_init = 0;
  492. X    }
  493. X
  494. X    goto get_next_token;
  495. X
  496. Xdo_action:
  497. X
  498. X#ifdef FLEX_REJECT_ENABLED
  499. X    /* remember matched text in case we back up due to trailing context */
  500. X    yy_full_match = yy_c_buf_p;
  501. X#endif
  502. X
  503. X    for ( ; ; )
  504. X    {
  505. X    YY_DO_BEFORE_ACTION
  506. X
  507. X#ifdef FLEX_DEBUG
  508. X    fprintf( stderr, "--accepting rule #%d\n", yy_act );
  509. X#endif
  510. X    switch ( yy_act )
  511. X        {
  512. Xcase 1:
  513. X# line 162 "menutoc.l"
  514. X{ BEGIN(M); lcnt++; }
  515. X    YY_BREAK
  516. Xcase 2:
  517. X# line 163 "menutoc.l"
  518. X{ ECHO; lcnt++; }
  519. X    YY_BREAK
  520. Xcase 3:
  521. X# line 164 "menutoc.l"
  522. XECHO;
  523. X    YY_BREAK
  524. Xcase 4:
  525. X# line 166 "menutoc.l"
  526. X{    writeword();
  527. X        if (valcnt2+1 >= MAXVAL) {
  528. X            fprintf(stderr,"menutoc: too many @s in menu\n");
  529. X            exit(1);
  530. X        }
  531. X        valpos2[valcnt2][0] = row;
  532. X        valpos2[valcnt2++][1] = col;
  533. X        col += 1;
  534. X};
  535. X    YY_BREAK
  536. Xcase 5:
  537. X# line 176 "menutoc.l"
  538. X{    writeword();
  539. X        if (valcnt+1 >= MAXVAL) {
  540. X            fprintf(stderr,"menutoc: too many %%s in menu\n");
  541. X            exit(1);
  542. X        }
  543. X        valpos[valcnt][0] = row;
  544. X        valpos[valcnt++][1] = col;
  545. X        col += 1;
  546. X};
  547. X    YY_BREAK
  548. Xcase 6:
  549. X# line 186 "menutoc.l"
  550. X{    if (yyleng > 4) writeword();
  551. X        else if (wordp) for (i=0; i<yyleng; i++) append(' ');
  552. X        col += yyleng;
  553. X};
  554. X    YY_BREAK
  555. Xcase 7:
  556. X# line 191 "menutoc.l"
  557. X{    writeword(); col = ((col + 8)/8)*8;
  558. X};
  559. X    YY_BREAK
  560. Xcase 8:
  561. X# line 194 "menutoc.l"
  562. X{    writeword(); col = 0; row += 1; lcnt++;
  563. X};
  564. X    YY_BREAK
  565. Xcase 9:
  566. X# line 197 "menutoc.l"
  567. X{        append(yytext[0]); col += 1;
  568. X};
  569. X    YY_BREAK
  570. Xcase 10:
  571. X# line 200 "menutoc.l"
  572. X{
  573. X        BEGIN(VAL); i = 0; j = 0; lcnt++;
  574. X        printf("# line %d \"%s\"\n", lcnt, infname);
  575. X};
  576. X    YY_BREAK
  577. Xcase 11:
  578. X# line 205 "menutoc.l"
  579. X{
  580. X        if (np+1 >= MAXVSTRINGS) {
  581. X            fprintf(stderr,"menutoc: too many VSTRINGs\n");
  582. X            exit(1);
  583. X        }
  584. X        BEGIN(O);
  585. X        multiple = special = 0;
  586. X        vmax = offset = mask = vshift = vmin = vrow = vcol = iflag = 0;
  587. X        state = 0;
  588. X};
  589. X    YY_BREAK
  590. Xcase 12:
  591. X# line 216 "menutoc.l"
  592. Xmultiple = atoi(yytext);
  593. X    YY_BREAK
  594. Xcase 13:
  595. X# line 218 "menutoc.l"
  596. X{
  597. X        if (bufp+yyleng >= MAXBUF) {
  598. X            fprintf(stderr,"menutoc: out of storage room\n");
  599. X            exit(1);
  600. X        }
  601. X        nlist[np][0] = bufp;
  602. X        strcpy(buf+bufp, yytext);
  603. X        bufp += yyleng+1;
  604. X        BEGIN(P);
  605. X};
  606. X    YY_BREAK
  607. Xcase 14:
  608. X# line 229 "menutoc.l"
  609. X;
  610. X    YY_BREAK
  611. Xcase 15:
  612. X# line 230 "menutoc.l"
  613. X{
  614. X        strcpy(visfunc, yytext);
  615. X        if (yyleng >= 20) {
  616. X            fprintf(stderr,"menutoc: vis name too long\n");
  617. X            exit(1);
  618. X        }
  619. X        BEGIN(Q);
  620. X};
  621. X    YY_BREAK
  622. Xcase 16:
  623. X# line 239 "menutoc.l"
  624. X;
  625. X    YY_BREAK
  626. Xcase 17:
  627. X# line 240 "menutoc.l"
  628. X{    lcnt++;
  629. X        if (special == 5) vmin = 1;
  630. X        else vmin = 0;
  631. X        if (offset < 0) vval = -offset;
  632. X        else vval = 0;
  633. X
  634. X        if (multiple) for (k=0; k<multiple; k++) {
  635. X            printf("\"%s%d\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
  636. X                buf+nlist[np][0], k+1, vrow, vcol, visfunc,
  637. X                vmin, vmax, vval);
  638. X            if (k+1 < multiple) {
  639. X            if (iflag) {
  640. X                if (i < valcnt) {
  641. X                vrow = valpos[i][0]; vcol = valpos[i++][1];
  642. X                } else
  643. X                fprintf(stderr,"menutoc: too many %%%%s\n");
  644. X            } else
  645. X                if (j < valcnt2) {
  646. X                vrow = valpos2[j][0]; vcol = valpos2[j++][1];
  647. X                } else
  648. X                fprintf(stderr,"menutoc: too many @@s\n");
  649. X            }
  650. X        }
  651. X        else
  652. X            printf("\"%s\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
  653. X                buf+nlist[np][0], vrow, vcol, visfunc,
  654. X                vmin, vmax, vval);
  655. X        if (multiple)
  656. X            printf("# line %d \"%s\"\n", lcnt, infname);
  657. X        nlist[np][1] = offset;
  658. X        nlist[np][2] = mask;
  659. X        nlist[np][3] = vshift;
  660. X        nlist[np][4] = multiple;
  661. X        nlist[np][5] = special;
  662. X        np++;
  663. X        BEGIN(VAL);
  664. X};
  665. X    YY_BREAK
  666. Xcase 18:
  667. X# line 278 "menutoc.l"
  668. X{
  669. X        k = (int)strtol(yytext, (char **)NULL, 0);
  670. X        switch (state) {
  671. X          case 0: vmax = k;   break;
  672. X          case 1: offset = k; break;
  673. X          case 2: mask = k;   break;
  674. X          case 3: vshift = k; break;
  675. X          case 4: vmin = k;   break;
  676. X                }
  677. X                ++state;
  678. X};
  679. X    YY_BREAK
  680. Xcase 19:
  681. X# line 290 "menutoc.l"
  682. X{    if (i < valcnt) {
  683. X            vrow = valpos[i][0];
  684. X            vcol = valpos[i][1];
  685. X            i++;
  686. X            iflag++;
  687. X        }
  688. X        else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
  689. X};
  690. X    YY_BREAK
  691. Xcase 20:
  692. X# line 298 "menutoc.l"
  693. X{    if (j < valcnt2) {
  694. X            vrow = valpos2[j][0];
  695. X            vcol = valpos2[j][1];
  696. X            j++;
  697. X        }
  698. X        else fprintf(stderr,"\nmenutoc: too many @@s\n");
  699. X};
  700. X    YY_BREAK
  701. Xcase 21:
  702. X# line 305 "menutoc.l"
  703. X{    vrow = -1;
  704. X        vcol = -1;
  705. X};
  706. X    YY_BREAK
  707. Xcase 22:
  708. X# line 308 "menutoc.l"
  709. X{
  710. X        special = yytext[1] - '0';
  711. X};
  712. X    YY_BREAK
  713. Xcase 23:
  714. X# line 311 "menutoc.l"
  715. XECHO;
  716. X    YY_BREAK
  717. Xcase 24:
  718. X# line 312 "menutoc.l"
  719. X{ ECHO; lcnt++; }
  720. X    YY_BREAK
  721. Xcase 25:
  722. X# line 314 "menutoc.l"
  723. X{
  724. X        lcnt++;
  725. X        /* make sure i,k will be used before declaring them */
  726. X        for (k=0; k<np; k++)
  727. X            if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
  728. X                printf("\tINT16 i, k;\n\n");
  729. X                break;
  730. X            }
  731. X        for (k=0; k<np; k++) dosetval(k);
  732. X        printf("# line %d \"%s\"\n", lcnt, infname);
  733. X};
  734. X    YY_BREAK
  735. Xcase 26:
  736. X# line 326 "menutoc.l"
  737. X{
  738. X        lcnt++;
  739. X        /* make sure i,j,k will be used before declaring them */
  740. X        for (k=0; k<np; k++)
  741. X            if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
  742. X                printf("\tINT16 i, j, k;\n\n");
  743. X                break;
  744. X            }
  745. X        for (k=0; k<np; k++) dogetval(k);
  746. X        printf("# line %d \"%s\"\n", lcnt, infname);
  747. X};
  748. X    YY_BREAK
  749. Xcase 27:
  750. X# line 338 "menutoc.l"
  751. Xprintf("%s", yytext+1);
  752. X    YY_BREAK
  753. Xcase 28:
  754. X# line 339 "menutoc.l"
  755. Xprintf("%s", yytext+1);
  756. X    YY_BREAK
  757. Xcase 29:
  758. X# line 341 "menutoc.l"
  759. X{    if (j < valcnt2) {
  760. X            printf("%d, %d", valpos2[j][0], valpos2[j][1]);
  761. X            j++;
  762. X        }
  763. X        else fprintf(stderr,"\nmenutoc: too many @@s\n");
  764. X};
  765. X    YY_BREAK
  766. Xcase 30:
  767. X# line 348 "menutoc.l"
  768. X{    if (i < valcnt) {
  769. X            printf("%d, %d", valpos[i][0], valpos[i][1]);
  770. X            i++;
  771. X        }
  772. X        else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
  773. X};
  774. X    YY_BREAK
  775. Xcase 31:
  776. X# line 355 "menutoc.l"
  777. XECHO;
  778. X    YY_BREAK
  779. Xcase 32:
  780. X# line 356 "menutoc.l"
  781. X{ ECHO; lcnt++; }
  782. X    YY_BREAK
  783. Xcase 33:
  784. X# line 358 "menutoc.l"
  785. XYY_DEFAULT_ACTION;
  786. X    YY_BREAK
  787. X
  788. Xcase YY_NEW_FILE:
  789. Xbreak; /* begin reading from new file */
  790. X
  791. Xcase YY_DO_DEFAULT:
  792. XYY_DEFAULT_ACTION;
  793. Xbreak;
  794. X
  795. Xcase YY_END_TOK:
  796. Xreturn ( YY_END_TOK );
  797. X
  798. Xdefault:
  799. XYY_FATAL_ERROR( "fatal flex scanner internal error" );
  800. X        }
  801. X
  802. Xget_next_token:
  803. X    {
  804. X    register int yy_curst;
  805. X    register char yy_sym;
  806. X
  807. X    YY_DO_BEFORE_SCAN
  808. X
  809. X    /* set up to begin running DFA */
  810. X
  811. X    yy_curst = yy_start;
  812. X
  813. X    if ( yy_ch_buf[yy_c_buf_p] == '\n' )
  814. X        ++yy_curst;
  815. X
  816. X    /* yy_b_buf_p points to the position in yy_ch_buf
  817. X     * of the start of the current run.
  818. X     */
  819. X
  820. X    yy_b_buf_p = yy_c_buf_p + 1;
  821. X
  822. X    do /* until the machine jams */
  823. X        {
  824. X        if ( yy_c_buf_p == yy_e_buf_p )
  825. X        { /* need more input */
  826. X        if ( yy_e_buf_p >= YY_BUF_LIM )
  827. X            { /* not enough room to do another read */
  828. X            /* see if we can make some room for more chars */
  829. X
  830. X            yy_n_chars = yy_e_buf_p - yy_b_buf_p;
  831. X
  832. X            if ( yy_n_chars >= 0 )
  833. X            /* shift down buffer to make room */
  834. X            for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
  835. X                {
  836. X                yy_buf_pos = yy_b_buf_p + yy_iii;
  837. X                yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
  838. X                yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
  839. X                }
  840. X
  841. X            yy_b_buf_p = 0;
  842. X            yy_e_buf_p = yy_n_chars;
  843. X
  844. X            if ( yy_e_buf_p >= YY_BUF_LIM )
  845. X            YY_FATAL_ERROR( "flex input buffer overflowed" );
  846. X
  847. X            yy_c_buf_p = yy_e_buf_p;
  848. X            }
  849. X
  850. X        else if ( yy_saw_eof )
  851. X            {
  852. Xsaweof:            if ( yy_b_buf_p > yy_e_buf_p )
  853. X            {
  854. X            if ( yywrap() )
  855. X                {
  856. X                yy_act = YY_END_TOK;
  857. X                goto do_action;
  858. X                }
  859. X            
  860. X            else
  861. X                {
  862. X                YY_INIT;
  863. X                yy_act = YY_NEW_FILE;
  864. X                goto do_action;
  865. X                }
  866. X            }
  867. X
  868. X            else /* do a jam to eat up more input */
  869. X            {
  870. X#ifndef FLEX_INTERACTIVE_SCANNER
  871. X            /* we're going to decrement yy_c_buf_p upon doing
  872. X             * the jam.  In this case, that's wrong, since
  873. X             * it points to the last non-jam character.  So
  874. X             * we increment it now to counter the decrement.
  875. X             */
  876. X            ++yy_c_buf_p;
  877. X#endif
  878. X            break;
  879. X            }
  880. X            }
  881. X
  882. X        YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
  883. X              YY_MAX_LINE );
  884. X
  885. X        if ( yy_n_chars == YY_NULL )
  886. X            {
  887. X            if ( yy_saw_eof )
  888. X    YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
  889. X            yy_saw_eof = 1;
  890. X            goto saweof;
  891. X            }
  892. X
  893. X        yy_e_buf_p += yy_n_chars;
  894. X        }
  895. X
  896. X        ++yy_c_buf_p;
  897. X
  898. X#ifdef FLEX_USE_ECS
  899. X        yy_sym = e[yy_ch_buf[yy_c_buf_p]];
  900. X#else
  901. X        yy_sym = yy_ch_buf[yy_c_buf_p];
  902. X#endif
  903. X
  904. X#ifdef FLEX_FULL_TABLE
  905. X        yy_curst = n[yy_curst][yy_sym];
  906. X
  907. X#else /* get next state from compressed table */
  908. X
  909. X        while ( c[b[yy_curst] + yy_sym] != yy_curst )
  910. X        {
  911. X        yy_curst = d[yy_curst];
  912. X
  913. X#ifdef FLEX_USE_MECS
  914. X        /* we've arrange it so that templates are never chained
  915. X         * to one another.  This means we can afford make a
  916. X         * very simple test to see if we need to convert to
  917. X         * yy_sym's meta-equivalence class without worrying
  918. X         * about erroneously looking up the meta-equivalence
  919. X         * class twice
  920. X         */
  921. X
  922. X        if ( yy_curst >= YY_TEMPLATE )
  923. X            yy_sym = m[yy_sym];
  924. X#endif
  925. X        }
  926. X
  927. X        yy_curst = n[b[yy_curst] + yy_sym];
  928. X
  929. X#endif
  930. X
  931. X        yy_st_buf[yy_c_buf_p] = yy_curst;
  932. X
  933. X        }
  934. X#ifdef FLEX_INTERACTIVE_SCANNER
  935. X    while ( b[yy_curst] != YY_JAM_BASE );
  936. X#else
  937. X    while ( yy_curst != YY_JAM );
  938. X    --yy_c_buf_p; /* put back character we jammed on */
  939. X
  940. X#endif
  941. X
  942. X    if ( yy_c_buf_p >= yy_b_buf_p )
  943. X        { /* we matched some text */
  944. X        yy_curst = yy_st_buf[yy_c_buf_p];
  945. X        yy_lp = l[yy_curst];
  946. X
  947. X#ifdef FLEX_REJECT_ENABLED
  948. Xfind_rule: /* we branch to this label when doing a REJECT */
  949. X#endif
  950. X
  951. X        for ( ; ; ) /* until we find what rule we matched */
  952. X        {
  953. X#ifdef FLEX_REJECT_ENABLED
  954. X        if ( yy_lp && yy_lp < l[yy_curst + 1] )
  955. X            {
  956. X            yy_act = a[yy_lp];
  957. X            goto do_action; /* "continue 2" */
  958. X            }
  959. X#else
  960. X        if ( yy_lp )
  961. X            {
  962. X            yy_act = yy_lp;
  963. X            goto do_action; /* "continue 2" */
  964. X            }
  965. X#endif
  966. X
  967. X        if ( --yy_c_buf_p < yy_b_buf_p )
  968. X            break;
  969. X
  970. X        yy_curst = yy_st_buf[yy_c_buf_p];
  971. X        yy_lp = l[yy_curst];
  972. X        }
  973. X        }
  974. X
  975. X    /* if we got this far, then we didn't find any accepting
  976. X     * states
  977. X     */
  978. X
  979. X    /* so that the default applies to the first char read */
  980. X    ++yy_c_buf_p;
  981. X
  982. X    yy_act = YY_DO_DEFAULT;
  983. X    }
  984. X    }
  985. X
  986. X    /*NOTREACHED*/
  987. X    }
  988. X
  989. X
  990. Xstatic int unput( c )
  991. Xchar c;
  992. X
  993. X    {
  994. X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */
  995. X
  996. X    if ( yy_c_buf_p == 0 )
  997. X    {
  998. X    register int i;
  999. X    register int yy_buf_pos = YY_BUF_MAX;
  1000. X
  1001. X    for ( i = yy_e_buf_p; i >= yy_c_buf_p; --i )
  1002. X        {
  1003. X        yy_ch_buf[yy_buf_pos] = yy_ch_buf[i];
  1004. X        yy_st_buf[yy_buf_pos] = yy_st_buf[i];
  1005. X        --yy_buf_pos;
  1006. X        }
  1007. X
  1008. X    yy_c_buf_p = YY_BUF_MAX - yy_e_buf_p;
  1009. X    yy_e_buf_p = YY_BUF_MAX;
  1010. X    }
  1011. X
  1012. X    if ( yy_c_buf_p <= 0 )
  1013. X    YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1014. X
  1015. X    if ( yy_c_buf_p >= yy_b_buf_p && yy_ch_buf[yy_c_buf_p] == '\n' )
  1016. X    yy_ch_buf[yy_c_buf_p - 1] = '\n';
  1017. X
  1018. X    yy_ch_buf[yy_c_buf_p--] = c;
  1019. X
  1020. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  1021. X    }
  1022. X
  1023. X
  1024. Xstatic int input()
  1025. X
  1026. X    {
  1027. X    int c;
  1028. X
  1029. X    YY_DO_BEFORE_SCAN
  1030. X
  1031. X    if ( yy_c_buf_p == yy_e_buf_p )
  1032. X    { /* need more input */
  1033. X    int yy_n_chars;
  1034. X
  1035. X    /* we can throw away the entire current buffer */
  1036. X    if ( yy_saw_eof )
  1037. X        {
  1038. X        if ( yywrap() )
  1039. X        return ( EOF );
  1040. X
  1041. X        YY_INIT;
  1042. X        }
  1043. X
  1044. X    yy_b_buf_p = 0;
  1045. X    YY_INPUT( yy_ch_buf, yy_n_chars, YY_MAX_LINE );
  1046. X
  1047. X    if ( yy_n_chars == YY_NULL )
  1048. X        {
  1049. X        yy_saw_eof = 1;
  1050. X
  1051. X        if ( yywrap() )
  1052. X        return ( EOF );
  1053. X
  1054. X        YY_INIT;
  1055. X
  1056. X        return ( input() );
  1057. X        }
  1058. X
  1059. X    yy_c_buf_p = -1;
  1060. X    yy_e_buf_p = yy_n_chars - 1;
  1061. X    }
  1062. X
  1063. X    c = yy_ch_buf[++yy_c_buf_p];
  1064. X
  1065. X    YY_DO_BEFORE_ACTION;
  1066. X
  1067. X    return ( c );
  1068. X    }
  1069. X# line 358 "menutoc.l"
  1070. X
  1071. Xdosetval(k)
  1072. Xint k;
  1073. X{    int m;
  1074. X
  1075. X    special  = nlist[k][5];
  1076. X
  1077. X    if (special == 1 || special == 3) k++;
  1078. X    else if (special == 2 || special == 4) k--;
  1079. X
  1080. X    bufp     = nlist[k][0];
  1081. X    offset   = nlist[k][1];
  1082. X    mask     = nlist[k][2];
  1083. X    vshift   = nlist[k][3];
  1084. X    multiple = nlist[k][4];
  1085. X
  1086. X    if (offset < 0) return;
  1087. X
  1088. X    if (multiple) for (m = 1; m <= multiple; m++)
  1089. X    {    outsetval(m); offset++;        }
  1090. X    else    outsetval(0);
  1091. X}
  1092. X
  1093. Xoutsetval(m)
  1094. Xint m;
  1095. X{
  1096. X    if (!mask && !special) {
  1097. X        printf("setval(\"%s", buf+bufp);
  1098. X        if (m) printf("%d", m);
  1099. X        printf("\",(INT16)data[RESERVESIZE+%d]);\n",offset);
  1100. X        return;
  1101. X    }
  1102. X
  1103. X    printf("i = (INT16)data[RESERVESIZE+%d]; ", offset);
  1104. X    if (mask) {
  1105. X        printf("i &= %d; ", mask);
  1106. X        if (vshift) printf("i >>= %d; ", vshift);
  1107. X    }
  1108. X
  1109. X    if (special == 2) printf("i += k << 1;\n");
  1110. X    else if (special == 4) printf("i += k << 7;\n");
  1111. X
  1112. X    if (special == 1 || special == 3) printf("k = i;\n");
  1113. X    else {
  1114. X        printf("setval(\"%s", buf+bufp);
  1115. X        if (m) printf("%d", m);
  1116. X        printf("\",i);\n");
  1117. X    }
  1118. X}
  1119. X
  1120. Xdogetval(k)
  1121. Xint k;
  1122. X{    int m;
  1123. X
  1124. X    bufp     = nlist[k][0];
  1125. X    offset   = nlist[k][1];
  1126. X    mask     = nlist[k][2];
  1127. X    vshift   = nlist[k][3];
  1128. X    multiple = nlist[k][4];
  1129. X    special  = nlist[k][5];
  1130. X
  1131. X    if (offset < 0) return;
  1132. X
  1133. X    if (multiple) for (m = 1; m <= multiple; m++)
  1134. X    {    outgetval(m); offset++;        }
  1135. X    else    outgetval(0);
  1136. X}
  1137. X
  1138. Xoutgetval(m)
  1139. Xint m;
  1140. X{
  1141. X    if (!mask && !special) {
  1142. X        printf("data[RESERVESIZE+%d] = ", offset);
  1143. X        printf("getval(\"%s", buf+bufp);
  1144. X        if (m) printf("%d", m);
  1145. X        printf("\");\n");
  1146. X        return;
  1147. X    }
  1148. X
  1149. X    if (special == 2 || special == 4)
  1150. X        printf("i = k; ");
  1151. X    else {
  1152. X        printf("i = getval(\"%s", buf+bufp);
  1153. X        if (m) printf("%d", m);
  1154. X        printf("\"); ");
  1155. X    }
  1156. X
  1157. X    if (special == 1) printf("k = i >> 1; i &= 1;\n");
  1158. X    else if (special == 3) printf("k = i >> 7; i &= 0x7f;\n");
  1159. X
  1160. X    if (mask) {
  1161. X        printf("j = data[RESERVESIZE+%d]; ", offset);
  1162. X        if (vshift) printf("i <<= %d; ", vshift);
  1163. X        printf("j &= ~%d; ", mask);
  1164. X        printf("i = j|i; ");
  1165. X    }
  1166. X    printf("data[RESERVESIZE+%d] = i;\n", offset);
  1167. X}
  1168. X
  1169. Xmain(argc, argv)
  1170. Xint argc;
  1171. Xchar **argv;
  1172. X{    char *basename();
  1173. X
  1174. X  if (argc > 1) {
  1175. X    infname = basename(argv[1]);
  1176. X    if (freopen(argv[1], "r", stdin) == NULL) {
  1177. X      perror("Can't open input file");
  1178. X      exit(1);
  1179. X    }
  1180. X  }
  1181. X  if (argc > 2) {
  1182. X    if (freopen(argv[2], "w", stdout) == NULL) {
  1183. X      perror("Can't open output file");
  1184. X      exit(1);
  1185. X    }
  1186. X  }
  1187. X
  1188. X    word[0] = 0;
  1189. X    BEGIN(IG);
  1190. X    yylex();
  1191. X    if (i < valcnt) fprintf(stderr,"\nmenutoc: not enough %%%%s\n");
  1192. X    if (j < valcnt2) fprintf(stderr,"\nmenutoc: not enough @@s\n");
  1193. X    exit(0);
  1194. X}
  1195. X
  1196. Xchar   *basename(s)
  1197. Xchar   *s;
  1198. X{
  1199. X    char   *p;
  1200. X    char   *strrchr();
  1201. X
  1202. X    if (p = strrchr (s, '/'))
  1203. X        return (++p);
  1204. X    else
  1205. X        return (s);
  1206. X}
  1207. X
  1208. Xappend(c)
  1209. Xchar c;
  1210. X{
  1211. X    if (wordp+1 >= MAXLINE) {
  1212. X        fprintf(stderr,"menutoc: string in menu too long\n");
  1213. X        exit(1);
  1214. X    }
  1215. X    if (!wordp) wcol = col;
  1216. X    word[wordp++] = c;
  1217. X    word[wordp] = 0;
  1218. X}
  1219. X
  1220. Xwriteword()
  1221. X{
  1222. X    if (wordp) {
  1223. X        while (word[--wordp] == ' ') ;
  1224. X        word[++wordp] = 0;
  1225. X        printf("%d,%d,\"%s\",\n", row, wcol, word);
  1226. X        wordp = 0;
  1227. X        word[wordp] = 0;
  1228. X    }
  1229. X}
  1230. END_OF_FILE
  1231. if test 30374 -ne `wc -c <'menutoc.c'`; then
  1232.     echo shar: \"'menutoc.c'\" unpacked with wrong size!
  1233. fi
  1234. # end of 'menutoc.c'
  1235. fi
  1236. echo shar: End of archive 11 \(of 15\).
  1237. cp /dev/null ark11isdone
  1238. MISSING=""
  1239. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  1240.     if test ! -f ark${I}isdone ; then
  1241.     MISSING="${MISSING} ${I}"
  1242.     fi
  1243. done
  1244. if test "${MISSING}" = "" ; then
  1245.     echo You have unpacked all 15 archives.
  1246.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1247. else
  1248.     echo You still need to unpack the following archives:
  1249.     echo "        " ${MISSING}
  1250. fi
  1251. ##  End of shell archive.
  1252. exit 0
  1253.  
  1254.